Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPARK-1663. Corrections for several compile errors in streaming code examples, and updates to follow API changes #589

Closed
wants to merge 1 commit into from

Conversation

srowen
Copy link
Member

@srowen srowen commented Apr 29, 2014

I gave the Streaming code examples, both Scala and Java, a test run today. I turned up a number of small errors, mostly compile errors in the Java examples. There were a few typos in the Scala too.

I also took the liberty of adding things like imports, since in several cases they are not obvious. Feel free to push back on some changes.

There's one thing I haven't quite addressed in the changes. JavaPairDStream uses the Java API version of Function2 in almost all cases, as JFunction2. However it uses scala.Function2 in:

  def reduceByKeyAndWindow(reduceFunc: Function2[V, V, V], windowDuration: Duration)
  :JavaPairDStream[K, V] = {
    dstream.reduceByKeyAndWindow(reduceFunc, windowDuration)
  }

Is that a typo?

Also, in Scala, I could not get this to compile:

val windowedWordCounts = pairs.reduceByKeyAndWindow(_ + _, Seconds(30), Seconds(10))
error: missing parameter type for expanded function ((x$1, x$2) => x$1.$plus(x$2))

You can see my fix below but am I missing something?

Otherwise I can say these all worked for me!

@AmplabJenkins
Copy link

Merged build triggered.

@AmplabJenkins
Copy link

Merged build started.

@techaddict
Copy link
Contributor

@srowen scala error is related to #550

@AmplabJenkins
Copy link

Merged build finished. All automated tests passed.

@AmplabJenkins
Copy link

All automated tests passed.
Refer to this link for build results: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/14566/

@@ -684,7 +694,7 @@ operation `reduceByKeyAndWindow`.

{% highlight scala %}
// Reduce last 30 seconds of data, every 10 seconds
val windowedWordCounts = pairs.reduceByKeyAndWindow(_ + _, Seconds(30), Seconds(10))
val windowedWordCounts = pairs.reduceByKeyAndWindow((a:Int,b:Int) => (a + b), Seconds(30), Seconds(10))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a space after the , - not a big deal I can fix on merge.

@pwendell
Copy link
Contributor

pwendell commented May 3, 2014

@srowen these are all great - thanks! I'm going to merge it.

For the reduceByKeyAndWindow issue, I think that's just an oversight that occurred during the Java 8 re-factoring, and just needs to be changed to JFunction2.

For the compile error, this is a sort of weird corner case with method overloading in Scala. I think you'll need to specify a type signature for the reduce function.

@asfgit asfgit closed this in 11d5494 May 3, 2014
asfgit pushed a commit that referenced this pull request May 3, 2014
…examples, and updates to follow API changes

I gave the Streaming code examples, both Scala and Java, a test run today. I turned up a number of small errors, mostly compile errors in the Java examples. There were a few typos in the Scala too.

I also took the liberty of adding things like imports, since in several cases they are not obvious. Feel free to push back on some changes.

There's one thing I haven't quite addressed in the changes. `JavaPairDStream` uses the Java API version of `Function2` in almost all cases, as `JFunction2`. However it uses `scala.Function2` in:

```
  def reduceByKeyAndWindow(reduceFunc: Function2[V, V, V], windowDuration: Duration)
  :JavaPairDStream[K, V] = {
    dstream.reduceByKeyAndWindow(reduceFunc, windowDuration)
  }
```

Is that a typo?

Also, in Scala, I could not get this to compile:
```
val windowedWordCounts = pairs.reduceByKeyAndWindow(_ + _, Seconds(30), Seconds(10))
error: missing parameter type for expanded function ((x$1, x$2) => x$1.$plus(x$2))
```

You can see my fix below but am I missing something?

Otherwise I can say these all worked for me!

Author: Sean Owen <[email protected]>

Closes #589 from srowen/SPARK-1663 and squashes the following commits:

65a906b [Sean Owen] Corrections for several compile errors in streaming code examples, and updates to follow API changes
(cherry picked from commit 11d5494)

Signed-off-by: Patrick Wendell <[email protected]>
@srowen
Copy link
Member Author

srowen commented May 4, 2014

Sounds good @pwendell , thanks for merging with the comma fix.

Should I open a separate issue for the JFunction2 question?

@srowen srowen deleted the SPARK-1663 branch May 4, 2014 08:16
pwendell pushed a commit to pwendell/spark that referenced this pull request May 12, 2014
SPARK-1076: Convert Int to Long to avoid overflow

Patch for PR apache#578.

Author: Xiangrui Meng <[email protected]>

Closes apache#589 and squashes the following commits:

98c435e [Xiangrui Meng] cast Int to Long to avoid Int overflow
pdeyhim pushed a commit to pdeyhim/spark-1 that referenced this pull request Jun 25, 2014
…examples, and updates to follow API changes

I gave the Streaming code examples, both Scala and Java, a test run today. I turned up a number of small errors, mostly compile errors in the Java examples. There were a few typos in the Scala too.

I also took the liberty of adding things like imports, since in several cases they are not obvious. Feel free to push back on some changes.

There's one thing I haven't quite addressed in the changes. `JavaPairDStream` uses the Java API version of `Function2` in almost all cases, as `JFunction2`. However it uses `scala.Function2` in:

```
  def reduceByKeyAndWindow(reduceFunc: Function2[V, V, V], windowDuration: Duration)
  :JavaPairDStream[K, V] = {
    dstream.reduceByKeyAndWindow(reduceFunc, windowDuration)
  }
```

Is that a typo?

Also, in Scala, I could not get this to compile:
```
val windowedWordCounts = pairs.reduceByKeyAndWindow(_ + _, Seconds(30), Seconds(10))
error: missing parameter type for expanded function ((x$1, x$2) => x$1.$plus(x$2))
```

You can see my fix below but am I missing something?

Otherwise I can say these all worked for me!

Author: Sean Owen <[email protected]>

Closes apache#589 from srowen/SPARK-1663 and squashes the following commits:

65a906b [Sean Owen] Corrections for several compile errors in streaming code examples, and updates to follow API changes
gzm55 pushed a commit to MediaV/spark that referenced this pull request Jul 17, 2014
SPARK-1076: Convert Int to Long to avoid overflow

Patch for PR apache#578.

Author: Xiangrui Meng <[email protected]>

Closes apache#589 and squashes the following commits:

98c435e [Xiangrui Meng] cast Int to Long to avoid Int overflow
bzhaoopenstack pushed a commit to bzhaoopenstack/spark that referenced this pull request Sep 11, 2019
1. Change job metadata from aarch64 to arm64
2. Remove useless nodeset "ubuntu-bionic-vxh-arm64"

Related-Bug: theopenlab/openlab#318
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants